<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>学员信息添加</title>
<style>
	*{margin: 0px auto;}
	#container{}
	h3{text-align: center;}
	form tr{border:1px #f5f5f5 solid;margin:10px;}
	.sp{width:40px;background-color: #f5f5f5;}
	.error{color:red}
</style>
<script type="text/javascript" src="${pageContext.request.contextPath}/script/jquery-1.10.2.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/script/jquery.validate.js"></script>
<script type="text/javascript">
	
	$(function(){
		$("#cancel").click(function(){
			location.href="index";
		});
		
		$("#form").validate({
			rules:{
				"student.name":{
					required:true
				},
				"student.gender":{
					required:true
				},
				"student.age":{
					required:true
				},
				"student.telephone":{
					required:true
				},
				"student.email":{
					required:true,
					email:true
				}
			},
			messages:{
				"student.name":{
					required:"请输入学生姓名"
				},
				"student.gender":{
					required:"请输入学生性别"
				},
				"student.age":{
					required:"请输入学生年龄"
				},
				"student.telephone":{
					required:"电话不能为空"
				},
				"student.email":{
					required:"请输入邮箱地址",
					email:"邮箱地址格式不正确"
				}
			}
		});
	});
</script>
</head>
<body>
	<div id="container">
		<div id="main">
			<h3>学员信息添加</h3>
			<form id="form" action="addStudent" method="post">
				<table>
					<tr>
						<td class="sp">姓名</td>
						<td><input type="text" name="student.name"/></td>
					</tr>
					<tr>
						<td class="sp">性别</td>
						<td><input type="text" name="student.gender"/></td>
					</tr>
					<tr>
						<td class="sp">年龄</td>
						<td><input type="text" name="student.age"/></td>
					</tr>
					<tr>
						<td class="sp">电话</td>
						<td><input type="text" name="student.telephone"/></td>
					</tr>
					<tr>
						<td class="sp">email</td>
						<td><input type="text" name="student.email"/></td>
					</tr>
					<tr>
						<td class="sp">班级</td>
						<td>
							<select name="student.classId.id">
								<c:forEach items="${classesList }" var="c">
									<option value="${c.id }">${c.name }</option>
								</c:forEach>
							</select>
						</td>
					</tr>
					<tr>
						<td colspan="2"><input type="submit" value="保存"/>&nbsp;&nbsp;
						<input type="button" id="cancel" value="取消"/>
						</td>
					</tr>
				</table>
				</form>
		</div>
	</div>
</body>
</html>